package com.ganjiangps.huochetou.service.impl;

import java.util.Date;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.ganjiangps.huochetou.mapper.PersonalManagementMapper;
import com.ganjiangps.huochetou.mapper.PersonalManagementUserMapper;
import com.ganjiangps.huochetou.model.PersonalManagementUser;
import com.ganjiangps.huochetou.service.PersonalManagementUserService;

/**
 * 人员添加
 * 
 * @author xiaoy
 *
 */
@Service
public class PersonalManagementUserServiceImpl extends ServiceImpl<PersonalManagementUserMapper, PersonalManagementUser>
		implements PersonalManagementUserService {

	@Resource
	private PersonalManagementMapper personalManagementMapper;

	@Override
	public List<PersonalManagementUser> selectUser(PersonalManagementUser prsonalManagementUser) {
		// TODO Auto-generated method stub
		return baseMapper.selectUser(prsonalManagementUser);
	}

	@Override
	@Transactional

	public boolean insert(PersonalManagementUser entity) {
		String[] baseids = entity.getBaseids();

		// AdminUser admin = (AdminUser)
		// SecurityUtils.getSubject().getPrincipal();
		// entity.setAddman(admin.getUsername());
		boolean flag = false;

		for (String baseid : baseids) {
			entity.setBaseid(Long.valueOf(baseid));
			entity.setAddtime(new Date());
			flag = super.insert(entity);
		}
		return flag;
	}

	@Override
	public List<PersonalManagementUser> listUsers(String pmno) {
		// TODO Auto-generated method stub
		return baseMapper.listUsers(pmno);
	}

}
